﻿Imports Magic.Core
Public Class TAG_REFERENCE
    Private _fourCC As String
    Public FilenameLen As Integer
    Public Filename As String
    Public Reference As HaloTag

    Public Property FourCC As String
        Get
            Return _fourCC
        End Get
        Set(value As String)
            _fourCC = value
        End Set
    End Property

    Public Sub Read(eR As EndianReader)
        _fourCC = eR.ReadFourCC
        eR.Position += 4
        FilenameLen = eR.ReadInt32
        eR.Position += 4
    End Sub
    Public Sub Write(eR As EndianWriter)
        eR.WriteFourCC(_fourCC)
        eR.Write(0)
        If Filename <> "" Then
            eR.Write(Filename.Length)
        Else
            eR.Write(0)
        End If
        eR.Write(-1)
    End Sub
    Public Function ReadRaw(eR As EndianReader) As Boolean
        If FilenameLen > 0 Then
            Filename = eR.ReadString(FilenameLen, True)
            Return True
        End If
        Return False
    End Function
    Public Sub WriteRaw(eR As EndianWriter)
        If Filename <> "" Then eR.Write(Filename, True)
    End Sub
End Class
